<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      #menu li,
      .out {
        padding: 10px 15px;
        background-color: #20bdff;
        width: 120px;
        text-align: center;
        color: white;
        border-radius: 2px;
        cursor: pointer;
        margin: 3px;
        float: left;
        list-style: none;
      }
      .over {
        background-color: sandybrown !important;
      }
      .shadow {
        box-shadow: 0px 0px 10px blue;
      }
    </style>
  </head>
  <body>
    <ul id="menu">
      <li>首页</li>
      <li>新闻资讯</li>
      <li>产品信息</li>
      <li>联系我们</li>
    </ul>
    <script>
      window.onload = function () {
        // 获取ul中的所有li列表项
        var lis = document.querySelector("#menu").children;
        for (var i = 0; i < lis.length; i++) {
          // 鼠标移入时，追加over和shadow样式
          lis[i].onmouseover = function () {
            this.className += " over shadow";
            console.log(this.className);
            console.log(this.classList);
          };
          //  鼠标移出时，设置样式为out
          lis[i].onmouseout = function () {
            this.className = "out";
          };
        }
      };
    </script>
  </body>
</html>
